<template>
	<view>
		<uni-nav-bar fixed @clickLeft="goorder" statusBar="true" left-icon="back" title="订单详情"></uni-nav-bar>
		<!-- 带取餐 -->
		<view class="block_1" v-if="orderinfo.status=='待取餐'">
			<view class="top">
				<image src="../static/icon/zhong.png" mode=""></image>
				<view class="">
					待取餐
				</view>
			</view>
			<view class="imgpre">
				<image src="/static/icon/ju.png" mode=""></image>
				<view class="textpoa">
					<view class="t1">
						取餐码
					</view>
					<view class="t2">
						{{orderinfo.takeCode}}
					</view>
					<view class="t3">
						请到店使用取餐码取餐
					</view>
				</view>
			</view>
			<countdown v-if="orderinfo.takeTimeBegin"
			 :timeBegin='orderinfo.takeTimeBegin' :timeEnd="orderinfo.takeTimeEnd" @opents='opents'></countdown>
		</view>
		<view class="block_2" v-if="orderinfo.status=='已退款'">
			<view class="">
				<image src="../static/orderi1.png" mode=""></image>
				<view class="t1">
					退款成功
				</view>
				<view class="t2">
					期待您的下次光临~
				</view>
			</view>
			<view class="its">
				<view class="its_l">合计</view>
				<view class="price3"><span>￥</span>{{orderinfo.orderAmount}}</view>
			</view>
		</view>
		<view class="block_3" v-if="orderinfo.status!='待取餐' && orderinfo.status!='已退款'">
			<!-- // 1待取餐 2退款成功 3 订单取消 4 订单完成 5已取餐 6退款中 7 已失效 -->
			<view class="">
				<image v-if="orderinfo.status=='已取消'||orderinfo.status=='已完成'||orderinfo.status=='待评价'" 
				src="../static/dui.png" mode=""></image>
				<!-- <image v-if="isstep==6" src="../static/tui.png" mode=""></image> -->
				<image v-if="orderinfo.status=='已失效'" src="../static/shi.png" mode=""></image>
				<view class="t1">
					<span v-if="orderinfo.status=='已取消'">订单已取消</span>
					<span v-if="orderinfo.status=='已完成'">订单已完成</span>
					<span v-if="orderinfo.status=='待评价'">已取餐</span>
					<!-- <span v-if="isstep==6">退款中</span> -->
					<span v-if="orderinfo.status=='已失效'">已失效</span>
				</view>
				<view class="t2">
					<!-- <span v-if="isstep==6">退款金额会在1-2个工作日原路退还至您的支付账户~</span> -->
					<span v-if="orderinfo.status=='已失效'">超时未取餐，订单已失效，期待您的下次光临~</span>
					<!-- <span >期待您的下次光临~</span> -->
				</view>
			</view>
		</view>
		<view class="tsimg" v-if="orderinfo.status=='待取餐'||orderinfo.status=='待评价'||orderinfo.status=='已完成'">
			<image src="/static/js.png" mode=""></image>
			<view class="test">
				累计为地球减少 <span>{{numk | smartWeight}}</span> 碳排放
			</view>
		</view>
		<view class="content">
			<view class="iconflex">
				<view class="left">
					<image src="/static/dp.png" mode=""></image>
					{{orderinfo.shopName}}-{{orderinfo.productName}}
				</view>
				<view class="right">
					<image src="/static/icon/dh.png" mode="" @click="$opennavigation(shopinfo)"></image>
					<image src="/static/icon/sj.png" mode="" @click="$phoneCall(shopinfo.shopPhone)"></image>
				</view>
			</view>
			<view class="" v-if="isexpand">
				<view class="its">
					<view class="its_l">商品种类</view>
					<view class="its_l">
						{{orderinfo.productCategory}}
					</view>
				</view>
				<view class="its">
					<view class="its_l">商品数量</view>
					<view class="its_l">{{orderinfo.productCount}}</view>
				</view>
				<view class="its">
					<view class="its_l">商品价格</view>
					<view class="price1"><span
							class="S1">￥{{orderinfo.productPriceOldBegin}}-{{orderinfo.productPriceOldEnd}}</span>
						￥{{orderinfo.productPrice}}</view>
				</view>
				<view class="border">
					<view class="its">
						<view class="its_l">消费券</view>
						<view class="price2">
							<span v-if="orderinfo.couponReceiveId">-￥{{orderinfo.couponAmount}}</span>
							<span v-else>无</span>
						</view>
					</view>
					<view class="its">
						<view class="its_l">合计</view>
						<view class="price3"><span>￥</span>{{orderinfo.payAmount}}</view>
					</view>
				</view>
				<view class="its">
					<view class="its_l">订单编号</view>
					<view class="its_l flex_b">{{orderinfo.orderNumber}}<span class="btn" @click="copy">复制</span></view>
				</view>
				<view class="its">
					<view class="its_l">支付方式</view>
					<view class="its_l">{{orderinfo.payType}}</view>
				</view>
				<view class="its">
					<view class="its_l">下单时间</view>
					<view class="its_l">{{orderinfo.createTime}}</view>
				</view>
				<view class="its">
					<view class="its_l">支付时间</view>
					<view class="its_l">{{orderinfo.payTime}}</view>
				</view>
			</view>
			<view class="check">
				<view class="" v-if="isexpand" @click="isexpand=!isexpand">
					收起 <uni-icons color="#D1CDCD" size="16" type="top"></uni-icons>
				</view>
				<view class="" v-else @click="isexpand=!isexpand">
					更多 <uni-icons color="#D1CDCD" size="16" type="down"></uni-icons>
				</view>
			</view>
		</view>
		<view class="k2">
			<view class="kflexl">
				<image src="/static/icon/wh.png" mode=""></image>
				你可能想知道
			</view>
			<view class="kflexr">
				<view class="">超时未取餐该怎么办？</view>
				<view class="icons" @click="$pageGo('/mypage/contactus/question')">更多帮助
					<uni-icons type="right" color="#29A85C" size="14"></uni-icons>
				</view>
			</view>
		</view>
		<view class="k34">
			<view class="">
				<view class="kflexl">
					<view class="kflexl">
						<image src="/static/icon/ql.png" mode=""></image>
						<view class="">
							福利群
						</view>
					</view>
					<view class="lyh">
						领优惠
					</view>
				</view>
				<view class="test">
					有问题，就找小薅，长按识别即可联系专属客服~
				</view>
			</view>
			<view class="rimg">
				<image show-menu-by-longpress :src="imgInfo.kfCode" mode=""></image>
			</view>
		</view>
		<view class="" style="height: 200rpx;"></view>
		<view class="footerbtn">
			<view class="cont">
				<view v-if="orderinfo.status == '待评价'" class="btn b1" style="margin-left: 20rpx;" @click="goevaluate">
					去评价
				</view>
				<view class="btn b1" @click="godetails">
					再来一单
				</view>
				<view v-if="orderinfo.status == '待取餐'" class="btn b2" style="margin-right: 20rpx;" @click="gorefund">
					申请退款
				</view>
				
			</view>
		</view>
		<clearts ref="popupts"></clearts>
	</view>
</template>
<script>
	import {
		ordersInfo,getimg
	} from '@/common/http.api.js';
	export default {
		data() {
			return {
				// 1待取餐 2退款成功 3 订单取消 4 订单完成 5已取餐 6退款中 7 已失效
				isexpand: false,
				orderinfo: {},
				shopinfo:{},
				id:'',
				imgInfo:{}
			};
		},
		computed:{
			numk(){
				return (this.orderinfo.productWeight *  this.orderinfo.productCount)* this.orderinfo.subCParam
			}
		},
		onLoad(option) {
			getimg({}).then(res=>{
				this.imgInfo = res.data
			})
			this.id = option.id
			ordersInfo({
				id: option.id
			}).then(res => {
				res.data.productCategory = res.data.productCategory.split(',')
				this.orderinfo = res.data
				this.shopinfo = res.data.shop
			})
		},
		methods: {
			copy() {
				uni.setClipboardData({
					data: this.orderinfo.orderNumber,
					success() {
						uni.showToast({
							title: '复制成功',
							icon: 'success'
						})
					}
				})
			},
			//申请退款
			gorefund() {
				uni.navigateTo({
					url:`/mainpage/orderrefund?id=${this.id}`
				})
			},
			//再来一单
			godetails(){
				uni.navigateTo({
					url: `/mainpage/details?productid=${this.orderinfo.productId}`
				})
			},
			opents() {
				this.$refs.popupts.open()
			},
			goorder() {
				uni.switchTab({
					url: '/pages/order/order'
				})
			},
			goevaluate() {
				uni.navigateTo({
					url:`/mainpage/orderevaluate?id=${this.id}`
				})
			},
			
		}
	}
</script>

<style lang="scss">
	page {
		background: #FBFBFB;
	}

	.block_1 {
		padding: 18rpx 20rpx;
		box-sizing: border-box;
		background: #fff;

		.top {
			display: flex;
			align-items: center;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 52rpx;
			color: #000000;

			image {
				width: 48rpx;
				height: 48rpx;
				margin-right: 10rpx;
			}



		}

		.imgpre {
			position: relative;
			margin: 40rpx auto;
			width: 416rpx;
			height: 251rpx;

			image {
				width: 416rpx;
				height: 251rpx;
			}

			.textpoa {
				text-align: center;
				position: absolute;
				width: 416rpx;
				height: 251rpx;
				padding: 24rpx;
				box-sizing: border-box;
				top: 0%;

				.t1 {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 28rpx;
					color: #000000;
				}

				.t2 {
					font-family: 'DINB';
					font-size: 80rpx;
					color: #000000;
				}

				.t3 {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #23633D;
					line-height: 33rpx;
					margin-top: 40rpx;
				}
			}
		}

		.flex1 {
			display: flex;
			align-items: center;
			height: 68rpx;
			background: #F3F3F3;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 24rpx;
			color: #000000;
			justify-content: space-between;
			padding: 0rpx 20rpx;
			box-sizing: border-box;
			width: 710rpx;
			margin: 0 auto;

			image {
				width: 32rpx;
				height: 33rpx;
			}
		}
	}

	.block_2 {
		font-family: PingFang SC, PingFang SC;
		text-align: center;
		background: #fff;

		image {
			width: 142rpx;
			height: 96rpx;
			margin-top: 46rpx;
		}

		.t1 {
			font-weight: bold;
			font-size: 32rpx;
			color: #000000;
			margin: 24rpx auto;
		}

		.t2 {
			font-weight: 500;
			font-size: 28rpx;
			color: #CE7034;
			margin-bottom: 20rpx;
		}

		.its {
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1px solid #eee;
			padding: 30rpx 20rpx;
			border-top: 1px solid #eee;

			.its_l {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #000000;
			}

			.price3 {
				font-family: 'DINB';
				font-weight: bold;
				font-size: 40rpx;
				color: #000000;

				span {
					font-size: 28rpx;
				}
			}
		}
	}


	.block_3 {
		font-family: PingFang SC, PingFang SC;
		text-align: center;
		background: #fff;

		image {
			width: 108rpx;
			height: 108rpx;
			margin-top: 46rpx;
		}

		.t1 {
			font-weight: bold;
			font-size: 32rpx;
			color: #000000;
			margin: 24rpx auto;
		}

		.t2 {
			font-weight: 500;
			font-size: 28rpx;
			color: #CE7034;
			padding-bottom: 20rpx;
			margin-bottom: 20rpx;
		}
	}

	.tsimg {
		width: 710rpx;
		height: 120rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 30rpx auto;

		image {
			width: 710rpx;
			height: 120rpx;
		}

		.test {
			position: absolute;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #FFFFFF;
			margin-top: 20rpx;

			span {
				font-family: 'DINB';
				font-size: 40rpx;
				margin: 0 10rpx;
			}
		}
	}

	.content {
		background: #fff;
		padding: 32rpx 20rpx;
		box-sizing: border-box;

		.iconflex {
			display: flex;
			align-items: center;
			justify-content: space-between;

			image {
				width: 32rpx;
				height: 33rpx;
			}

			.left {
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 30rpx;
				color: #000000;
				display: flex;
				align-items: center;

				image {
					margin-right: 6rpx;
				}
			}

			.right {
				image {
					margin-left: 30rpx;
				}
			}
		}

		.its {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin: 30rpx auto;

			.its_l {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #000000;
			}

			.price1 {
				font-family: 'DINB';
				font-size: 28rpx;
				color: #000000;

				.S1 {
					font-family: 'FINE';
				}

				span {
					font-weight: 400;
					font-size: 24rpx;
					color: #D1CDCD;
					text-decoration: line-through;
					margin-right: 6rpx;
				}
			}

			.price2 {
				font-family: 'DINB';
				font-size: 28rpx;
				color: #CE7034;
			}

			.price3 {
				font-family: 'DINB';
				font-size: 40rpx;
				color: #000000;

				span {
					font-size: 28rpx;
				}
			}

			.btn {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 20rpx;
				color: #FFFFFF;
				height: 32rpx;
				background: #29A85C;
				text-align: center;
				line-height: 32rpx;
				padding: 0rpx 10rpx;
				margin-left: 10rpx;
			}
		}

		.check {
			text-align: center;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #D1CDCD;
			margin: 30rpx auto 0rpx;
		}

		.border {
			border-top: 1px solid #eee;
			border-bottom: 1px solid #eee;
		}
	}

	.k2 {
		width: 710rpx;
		height: 140rpx;
		background: #F3F3F3;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		margin: 20rpx auto 0rpx;
		padding: 24rpx 20rpx;
		box-sizing: border-box;

		.kflexl {
			display: flex;
			align-items: center;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 30rpx;
			color: #000000;

			image {
				width: 32rpx;
				height: 32rpx;
				margin-right: 6rpx;
			}
		}

		.kflexr {
			display: flex;
			justify-content: space-between;
			align-items: center;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #979797;
			margin-top: 10rpx;

			.icons {
				display: flex;
				align-items: center;
				color: #29A85C;
			}
		}

	}

	.footerbtn {
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		border-top: 1px solid #eee;
		position: fixed;
		bottom: 0%;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);

		.cont {
			display: flex;
			padding: 10rpx 20rpx;
			height: 120rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			align-items: center;
			flex-direction: row-reverse;

			.btn {
				width: 240rpx;
				height: 92rpx;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				line-height: 92rpx;
				text-align: center;
			}
			.b1 {
				border: 2rpx solid #000000;
				color: #000;
			}
			.b2 {
				color: #D9D9D9;
				border: 2rpx solid #D9D9D9;
			}
		}
	}
</style>